package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.utils.getTimer;
	
	/**
	 * ...
	 * @author Sang Tian
	 */
	public class Main extends Sprite 
	{
		private var _terminal:Terminal;
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			_terminal = new Terminal(300, 200);
			_terminal.setTextFormat( {"font": "Courier", "size": 24 } );
			addChild(_terminal);
			stage.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
			stage.addEventListener(KeyboardEvent.KEY_DOWN, _terminal.input);
		}
		
		private function handleEnterFrame(e:Event):void 
		{
			var time:int = getTimer();
			_terminal.refresh(time);
		}
		
	}
	
}